package com.pelli.imarket.client.store;

import java.util.Iterator;
import java.util.Set;

import com.extjs.gxt.ui.client.data.BaseModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;

public class JsonModelData extends BaseModelData {





	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	
	
	public JsonModelData(JSONObject row){
		Set<String> keySet = row.keySet();
		Iterator<String> keys = keySet.iterator();
		while (keys.hasNext()) {
			String key = (String) keys.next();
			JSONValue jsonValue = row.get(key);
			if(jsonValue.isArray()==null){
				System.out.println("----"+key+": "+jsonValue);
				if(jsonValue.isString()!=null){
					set(key,jsonValue.isString().stringValue());
				}
				if(jsonValue.isBoolean()!=null){
					set(key,jsonValue.isBoolean().booleanValue());
				}
				if(jsonValue.isString()!=null){
					set(key,jsonValue.isString().stringValue());
				}
				if(jsonValue.isNumber()!=null){
					set(key,jsonValue.isNumber().doubleValue());
				}
				if(jsonValue.isNull()!=null){
					set(key,jsonValue.isNull());
				}
			}
		}
		
	}
}
